<template>
  <div class="top-container">
    <div class="left-box">
      <div class="icon-wrapper">
        <span class="iconfont icon-home" @click="gohome"></span>
        <span class="iconfont icon-sami-select"></span>
        <span class="iconfont icon-full-screen" @click="fullscreen"></span>
      </div>
      <div class="history-wrapper">
        <span class="iconfont icon-arrow-lift" @click="goback"></span>
        <span class="iconfont icon-arrow-right" @click="goforward"></span>
      </div>
    </div>
    <div class="right-box">
      <div class="el-input el-input--small el-input--prefix">
        <input
          @keyup.enter="search"
          type="text"
          autocomplete="off"
          placeholder="搜索"
          class="el-input__inner"
          v-model="query"
        />
        <span class="el-input__prefix">
          <i class="el-input__icon el-icon-search"></i>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import screenfull from "screenfull";
export default {
  name: "top",
  data() {
    return {
      s: "",
      query: ""
    };
  },
  methods: {
    search() {
      if (this.query == "") {
        console.log(this.query);
        this.$message.warning("请输入内容");
      } else {
        this.string = this.query;
        console.log(this.$route.path);
        this.$router.push("/result?query=" + this.query);
      }
    },
    goback() {
        history.back();
    },
    goforward() {
      history.forward();
    },
    gohome() {
      this.$router.push("/");
    },
    fullscreen() {
      if (!screenfull.isFullscreen) {
        screenfull.toggle();
      }
    }
  }
};
</script>

<style scoped>
.icon-wrapper {
  margin-top: 1rem;
}
</style>
